﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Kaiser.Infrastructure.Context;
using Kaiser.Infrastructure.InversionOfControl;
using Kaiser.Models;
using Kaiser.Models.JsonModels;
using Kaiser.Services;

namespace Kaiser.Modules.Admin.Controllers
{
    public class SystemController : Controller
    {
       // private readonly ISiteService _siteService;
       // private readonly IBulletinService _bulletinService;
        private readonly IPermissionService _perService;
        private readonly KaiserContext _context;
        private readonly IDependencyInjector _dependencyInjector;
        private readonly IUserService _userService;
        public SystemController(IUserService userService)
        {
            _userService = userService;
        }


        public ActionResult ChangePassword()
        {
            return View();
        }

        [HttpPost]
        public ActionResult ChangePassword(FormCollection input)
        {
            var vmobject = new JsonReturnMessages();

            try
            {
                vmobject.Data = null;
                vmobject.success = true;
                vmobject.msg = "操作成功!";
            }
            catch (Exception ex)
            {
                vmobject.success = false;
                vmobject.msg = ex.Message;
            }

            return Json(vmobject);
        }

        public ActionResult ChangeProfile()
        {
            return View();
        }

        [HttpPost]
        public ActionResult ChangeProfile(FormCollection input)
        {
            return View();
        }

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Login()
        {
            return View();
        }

        private User SignIn()
        {
            return null;
        }

        [HttpPost]
        public ActionResult Login(string username, string password)
        {
            var result=new JsonReturnMessages();
            var errMsg = new List<string>();
       
            if (_userService.IsExists(username) )
            {
               //   _userService.SignIn()
            }
            else
            {
                errMsg.Add("用户名不存在！");
            }

            return View();
        }


        #region 用户管理
        public ActionResult UserList()
        {
            return View();
        }

        public ActionResult GetUserList(PagingInfo pageinfo, FormCollection form)
        {
            var result = "";
            return Content(result);
        }
        #endregion
    }
}
